package com.newcamping.camp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.newcamping.common.annotation.Log;
import com.newcamping.common.core.controller.BaseController;
import com.newcamping.common.core.domain.AjaxResult;
import com.newcamping.common.enums.BusinessType;
import com.newcamping.camp.domain.CCamp;
import com.newcamping.camp.service.ICCampService;
import com.newcamping.common.utils.poi.ExcelUtil;
import com.newcamping.common.core.page.TableDataInfo;

/**
 * 营地管理Controller
 * 
 * @author zjz
 * @date 2024-10-22
 */
@RestController
@RequestMapping("/camp/camp")
public class CCampController extends BaseController
{
    @Autowired
    private ICCampService cCampService;

    /**
     * 查询营地管理列表
     */
    @PreAuthorize("@ss.hasPermi('camp:camp:list')")
    @GetMapping("/list")
    public TableDataInfo list(CCamp cCamp)
    {
        startPage();
        List<CCamp> list = cCampService.selectCCampList(cCamp);
        return getDataTable(list);
    }

    /**
     * 导出营地管理列表
     */
    @PreAuthorize("@ss.hasPermi('camp:camp:export')")
    @Log(title = "营地管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CCamp cCamp)
    {
        List<CCamp> list = cCampService.selectCCampList(cCamp);
        ExcelUtil<CCamp> util = new ExcelUtil<CCamp>(CCamp.class);
//        util.exportExcel(response, list, "营地管理数据");
    }

    /**
     * 获取营地管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('camp:camp:query')")
    @GetMapping(value = "/{campId}")
    public AjaxResult getInfo(@PathVariable("campId") String campId)
    {
        return success(cCampService.selectCCampByCampId(campId));
    }

    /**
     * 新增营地管理
     */
    @PreAuthorize("@ss.hasPermi('camp:camp:add')")
    @Log(title = "营地管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CCamp cCamp)
    {
        return toAjax(cCampService.insertCCamp(cCamp));
    }

    /**
     * 修改营地管理
     */
    @PreAuthorize("@ss.hasPermi('camp:camp:edit')")
    @Log(title = "营地管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CCamp cCamp)
    {
        return toAjax(cCampService.updateCCamp(cCamp));
    }

    /**
     * 删除营地管理
     */
    @PreAuthorize("@ss.hasPermi('camp:camp:remove')")
    @Log(title = "营地管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{campIds}")
    public AjaxResult remove(@PathVariable String[] campIds)
    {
        return toAjax(cCampService.deleteCCampByCampIds(campIds));
    }
}
